package ace.module.stock.core.impl.manager;

import ace.module.common.core.impl.manager.EntityOfAppManager;
import ace.module.stock.api.enums.WmsStockRecordActionTypeEnum;
import ace.module.stock.api.model.dto.WmsStockRecordDto;
import ace.module.stock.api.model.input.WmsStockActionTypeRecordInput;
import ace.module.stock.core.impl.dao.entity.WmsStock;
import ace.module.stock.core.impl.dao.entity.WmsStockRecord;
import java.util.List;

/**
 * 库存变更记录,保存1年 spring data jdbc querydsl rsql manager.
 *
 * @author Caspar
 */
public interface WmsStockRecordManager extends EntityOfAppManager<WmsStockRecord, Long, WmsStockRecordDto> {


  WmsStockRecord buildAddRecord(Long wmsAppId, Long stockId, Long quantity, String userSn);

  WmsStockRecord buildSubtractRecord(Long wmsAppId, Long stockId, Long quantity, String userSn);

  WmsStockRecord buildModifyRecord(Long wmsAppId, Long stockId, Long quantity, String userSn, WmsStockRecordActionTypeEnum actionTypeEnum);

  WmsStockRecord buildModifyRecord(Long wmsAppId, Long stockId, Long quantity, String batchSn, String remark, WmsStockRecordActionTypeEnum actionTypeEnum);

  List<WmsStockRecord> buildModifyRecord(Long wmsAppId, String batchSn, List<WmsStock> skuWmsStocks, List<WmsStockActionTypeRecordInput> wmsStockActionTypeRecordInputs);

  List<WmsStockRecord> buildAddOrSubtractReverseRecord(String reverseBatchSn, List<WmsStockRecord> preWmsStockRecords);

  WmsStockRecord buildAddOrSubtractReverseRecord(String reverseBatchSn, WmsStockRecord preWmsStockRecord);

  long countByWmsAppIdAndStockIdInAndBatchSnAndActionType(Long wmsAppId, List<Long> stockIds, String batchSn, WmsStockRecordActionTypeEnum actionTypeEnum);

  List<WmsStockRecord> getByWmsAppIdAndBatchSnAndReverseFlagIsNoneAndActionTypeInAddSubtract(Long wmsAppId, String batchSn);

}